home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
GenericFifo.h,v
< prev
next >
Wrap
Text File
|
1989-02-23
|
4KB
|
178 lines
head 3.2;
branch ;
access ;
symbols ;
locks grunwald:3.2; strict;
comment @ * @;
3.2
date 89.02.20.15.34.42; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.49.48; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.10.30.13.05.44; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.05; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
//
// Define the following things:
// FIFO_NAME -- the name of the fifo type
// FIFO_INDEX -- the index type; defaults to unsigned short
// FIFO_ITEM -- the type name for an item; should be typedefed
// FIFO_INDEX_NULL -- the null value for the heap index; defaults to 65535
// FIFI_BASE_CLASS -- the base class for this derived FIFO
//
#include "Awesime.h"
#include "Generic.h"
#ifndef FIFO_INDEX
#define FIFO_INDEX unsigned short
#endif
#ifndef FIFO_INDEX_NULL
#define FIFO_INDEX_NULL 0xffff
#endif
#ifndef FIFO_BASE_CLASS
#define FIFO_BASE_CLASS public Awesime
#endif
typedef FIFO_ITEM GENERIC2(FIFO_NAME,Item);
typedef FIFO_INDEX GENERIC2(FIFO_NAME,Index);
class FIFO_NAME : FIFO_BASE_CLASS {
GENERIC2(FIFO_NAME,Item) *list;
GENERIC2(FIFO_NAME,Index) allocatedSize;
GENERIC2(FIFO_NAME,Index) listHead;
GENERIC2(FIFO_NAME,Index) listTail;
char *pValid;
unsigned int listElements;
inline GENERIC2(FIFO_NAME,Index) advance(GENERIC2(FIFO_NAME,Index) i) {
return( ((i+1) >= allocatedSize) ? (0) : (i+1) );
}
public:
inline FIFO_NAME(int defaultLength = 0, bool xdebug = 0) : (xdebug) {
listHead = listTail = 0;
listElements = 0;
allocatedSize = 0;
list = 0;
pValid = 0;
if (defaultLength > 0) {
reSize(defaultLength);
}
}
virtual ~FIFO_NAME();
void reSize(int howMany);
//
// Operations on the list
//
virtual void add(GENERIC2(FIFO_NAME,Item) *t);
virtual bool remove(GENERIC2(FIFO_NAME,Item) *item);
virtual bool removeIfFound(GENERIC2(FIFO_NAME,Item)* item);
//
// The next four members allow you to search a FIFO_NAME and mark
// items as invalid.
//
// doStart initilizes the index and returns the first item in the list.
// doNext moves to the next item and returns that item.
// Both return a bool indicating whether the value in item has any
// meaning. When bool=FALSE, you've searched everything.
// Call doDone at the end to insure compatibility with subclasses.
//
virtual bool doStart( GENERIC2(FIFO_NAME,Index) &index,
GENERIC2(FIFO_NAME,Item)* item);
virtual bool doDelete(GENERIC2(FIFO_NAME,Index) &index);
virtual bool doNext( GENERIC2(FIFO_NAME,Index) &index,
GENERIC2(FIFO_NAME,Item)* item);
virtual void doDone();
inline bool valid(GENERIC2(FIFO_NAME,Index) index) {
return ( pValid[index] );
}
inline GENERIC2(FIFO_NAME,Item) & item(GENERIC2(FIFO_NAME,Index) i) {
return( list[i] );
}
inline GENERIC2(FIFO_NAME,Index) maxIndex() {
return(allocatedSize);
}
virtual bool isEmpty();
virtual unsigned int size();
virtual void classPrintOn(ostream& s);
virtual const char* classIsA();
};
#undef FIFO_NAME
#undef FIFO_ITEM
#undef FIFO_KEY
#undef FIFO_INDEX
#undef FIFO_BASE_CLASS
@
3.1
log
@Steay version
@
text
@@
1.2
log
@*** empty log message ***
@
text
@@
1.1
log
@Initial revision
@
text
@d1 6
@